package com.headfirst.factory.abstractfactory;


import com.headfirst.factory.abstractfactory.pizza.Pizza;
import com.headfirst.factory.abstractfactory.pizzastore.ChicagoPizzaStore;
import com.headfirst.factory.abstractfactory.pizzastore.NYPizzaStore;
import com.headfirst.factory.abstractfactory.pizzastore.PizzaStore;
import com.headfirst.factory.factorymethod.myEnums.PizzaType;
import org.junit.Test;

/**
 * @author sunhongguang
 * @create 2022-01-23-21:55
 */
public class PizzaTestDriver {

    @Test
    public void test1(){
        PizzaStore nyPizzaStore = new NYPizzaStore();
        PizzaStore chicagoPizzaStore = new ChicagoPizzaStore();

        // 在纽约地区的披萨商店里订购一个芝士风味的披萨
        Pizza pizza = nyPizzaStore.orderPizza(PizzaType.CHEESE.getDesc());
        System.out.println("Ethan ordered a "+pizza.getName()+"\n");
        System.out.println("################################");

        // 在芝加哥地区的披萨商店里订购一个芝士风味的披萨
        Pizza pizza1 = chicagoPizzaStore.orderPizza(PizzaType.CHEESE.getDesc());
        System.out.println("Joel ordered a "+pizza1.getName()+"\n");
        System.out.println("################################");
        
        // 在芝加哥地区的披萨商店里面点的披萨没有指定类型，则会给顾客制作一份默认的原味披萨
        Pizza pizza2 = chicagoPizzaStore.orderPizza(null);
        System.out.println("SHG ordered a "+pizza2.getName()+"\n");
        System.out.println(pizza2);
        
        //// 这里模拟抽象的披萨商店类没有任何一家具体的实现类的情况，此时用户如果还是可以购买披萨的
        //// 只不过购买的是默认的原味披萨
        //PizzaStore pizzaStore = new PizzaStore() {
        //    @Override
        //    protected Pizza createPizza(String type) {
        //        return this.orderPizza(type);
        //        //return this.createOriginalFlavorPizza();
        //    }
        //};
        //
        //Pizza pizza3 = pizzaStore.orderPizza(null);
        ////Pizza originalFlavorPizza = pizzaStore.createOriginalFlavorPizza();
        //System.out.println("XXQ ordered a "+pizza3.getName()+"\n");
    }
}
